package com.jie.educms.controller;

import com.jie.commonutils.ResultEntity;
import com.jie.educms.entity.CrmBanner;
import com.jie.educms.service.CrmBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前台系统的banner显示接口
 * </p>
 * @author XieZhiJie
 * @create 2020-10-14 21:26
 */
//@CrossOrigin  // 解决跨域问题
@RestController
@RequestMapping("/educms/bannerfront")
public class BannerFrontController {

    private final CrmBannerService crmBannerService;

    @Autowired
    public BannerFrontController(CrmBannerService crmBannerService) {
        this.crmBannerService = crmBannerService;
    }

    /**
     * 查询所有的banner
     * @return  返回所有的banner信息
     */
    @GetMapping("/getAllBanner")
    public ResultEntity getAllBanner() {
        List<CrmBanner> list = crmBannerService.selectAllBanner();
        return ResultEntity.ok().data("list", list);
    }

}
